package com.jx.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.jx.model.User;
import com.jx.service.UserService;
import com.jx.servicrimpl.UserServiceImpl;

public class UpdateUserController extends HttpServlet{
	UserService updateuser = new UserServiceImpl();
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
		throws ServletException, IOException {
	// TODO Auto-generated method stub
	doPost(req, resp);
}
@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
	 req.setCharacterEncoding("utf8");
	   PrintWriter  pw =  resp.getWriter();
	   int  uid = Integer.parseInt(req.getParameter("uid"));
	   String uaccount = req.getParameter("uaccount");
		String upsw = req.getParameter("upsw");
		String ucard = req.getParameter("ucard");
		String uname = req.getParameter("uname");
		String usex = req.getParameter("usex");
		String uphone = req.getParameter("uphone");
		String uaddress = req.getParameter("uaddress");
		String upicture = req.getParameter("upicture");
		User user = new User(uid, uaccount, upsw, ucard, uname, usex, uphone, uaddress, upicture);
	  
		
	
		if (updateuser.updateUser(user)==true) {
	    	
			pw.write("1");
		}
	    else {
	    	
	    	pw.write("0");
		}
	  }
	  
	

}

